package rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import services.OrdenCompraService;
import services.XMLService;
import conexionRemota.ConexionRemota;

public class ClienteRMI implements ConexionRemota{

	private static ClienteRMI instancia = null;
	
	private ClienteRMI(){}
	
	public static ClienteRMI getInstancia(){
		if(instancia == null){
			instancia = new ClienteRMI();
		}
		return instancia;
	}
	
	public XMLService getXMLService(){
		XMLService xmlService = null;
		try {
			xmlService = (XMLService)Naming.lookup ("//localhost/XMLService");
			return xmlService;
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return xmlService;
	}
	
	public OrdenCompraService getOrdenCompraService(){
		OrdenCompraService ocService = null;
		try {
			ocService = (OrdenCompraService)Naming.lookup ("//localhost/OrdenCompraService");
			return ocService;
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ocService;
	}
}
